package sn_log.share;

public class Operate
{
    private static Operate instance=null;

    private Operate()
    {//{{{
        this.shutdown=false;
        this.worker=new Worker();
        this.worker.status=ThreadStatus.RUNNING;
    }//}}}

    public static synchronized Operate getInstance()
    {//{{{
        if(instance == null)
        {
            instance=new Operate();
        }
        return instance;
    }//}}}

    private static enum ThreadStatus { RUNNING, STOPPED };

    private boolean shutdown;

    class Worker
    {//{{{
        ThreadStatus status; 
    }//}}}
    private Worker worker;

    public synchronized void shutdown()
    {//{{{
        this.shutdown=true;
    }//}}}

    public synchronized boolean isShutdown()
    {//{{{
        return this.shutdown;
    }//}}}

    public synchronized boolean isWorkerRunning()
    {//{{{
        return this.worker.status == ThreadStatus.RUNNING;
    }//}}}

    public synchronized void workerStop()
    {//{{{
        this.worker.status=ThreadStatus.STOPPED;
    }//}}}

}
